#include<queue>
#include<iostream>
using namespace std;
int main(){
	int n,m,i,k,e,flag=1;
	queue<int>q;
	cin>>n>>m;
	for(i=0;i<n;i++)
		q.push(i+1);
	if(n<m||m<1) {
	    cout<<"error!";
	    return 0;
	}
	while(!q.empty()){
		k=m-1;
	   while(k--&&!q.empty()){
	   	  e=q.front(); 
		  q.pop();
		  q.push(e);
		}
	   e=q.front();
	   if(flag){
	      cout<<e; 
	      flag=0;
	   }
	   else cout<<" "<<e; 
	   q.pop();	
	}
	return 0;
}
